import VueRouter from "vue-router";
import Home from "../view/Home";
import Vue from "vue";
Vue.use(VueRouter);
/**
 * 1.普通的引入方式 import login from ‘@/components/login’
 * 优点: 易理解，
 * 缺点:webpack在打包的时候会把整个路由打包成一个js文件，如果页面一多，会导致这个文件非常大，加载缓慢
 *
 * 2. 异步组件技术
 *  component: (resolve) => require(['@/views/login/login'], resolve)
 *
 * 3. 使用动态的import()语法(推荐使用)
 *  component: () => import('@/views/login/login')
 */
const router = new VueRouter({
  mode: "history",
  routes: [
    {
      path: "/",
      name: "Home",
      component: Home,
      children: [
        {
          path: "/voide",
          name: "Voide",
          component: (resolve) => require(["@/view/voide"], resolve),
        },

        // 根据id 创建页面
        {
          path: "/trends:userId",
          name: "Trends",
          component: (resolve) => require(["@/view/trends"], resolve),
        },
      ],
    },
  ],
});

export default router;
